/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufrgs.inf.prav.jsf.components;

import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

/**
 *
 * @author Fernando
 */
public class ScriptComponent extends PravBaseComponent{

    public static final String COMPONENT_FAMILY = "PRAV_SCRIPT";
    public static final String COMPONENT_TYPE = "PRAV_SCRIPT";

    //attributes
    private String charset, defer, src, xmlSpace, language, type;

    public ScriptComponent(){

    }

    @Override
    public void encodeBegin(FacesContext context) throws IOException {
		ResponseWriter writer =
			context.getResponseWriter();
		writer.startElement("script", this);

        //fix href att
        src = makeFinalReference(src);

        //atts
        writer.writeAttribute("charset", charset, "charset");
        writer.writeAttribute("defer", defer, "defer");
        writer.writeAttribute("src", src, "src");
        writer.writeAttribute("xml:space", xmlSpace, "xmlSpace");
        writer.writeAttribute("language", language, "language");
        writer.writeAttribute("type", type, "type");

        addBaseAttributes(writer);
        writer.flush();

	}

    @Override
    public void encodeEnd(FacesContext context)
            throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        writer.endElement("script");
        writer.flush();
//        return;
    }

    // <editor-fold defaultstate="collapsed" desc="Getters and Setters">
    public String getCharset() {
        return charset;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    public String getDefer() {
        return defer;
    }

    public void setDefer(String defer) {
        this.defer = defer;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getSrc() {
        return src;
    }

    public void setSrc(String src) {
        this.src = src;
    }

    public String getXmlSpace() {
        return xmlSpace;
    }

    public void setXmlSpace(String xmlSpace) {
        this.xmlSpace = xmlSpace;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    // </editor-fold>

}
